package jpsearchcore;

import java.util.ArrayList;
import java.util.List;

public class Source {
	
	private String SourceElementType = "";
	private List<SourceElement> sourceElements = new ArrayList<SourceElement>();
	private String CreationMethod = "";
	private String CreationDescription = "";
	
	public Source(){}
	
	public Source(String sourceElementType, List<SourceElement> sourceElements,
			String creationMethod, String creationDescription) {
		SourceElementType = sourceElementType;
		this.sourceElements = sourceElements;
		CreationMethod = creationMethod;
		CreationDescription = creationDescription;
	}

	public Source(SourceType st){
		try{
			SourceElementType = st.getSourceElementType().trim();
		}
		catch(NullPointerException e){}	
		/////
		
		for(jpsearchcore.SourceType.SourceElement i : st.getSourceElement()){
			sourceElements.add(new SourceElement(i));
		}	
		//////
		try{
			CreationMethod = st.getCreationMethod().trim();
		}
		catch(NullPointerException e){}	
		//////
		try{
			CreationDescription = st.getCreationDescription().trim();
		}
		catch(NullPointerException e){}			
	}
	
	//Getters
	public String getSourceElementType() {
		return SourceElementType;
	}

	public List<SourceElement> getSourceElements() {
		return sourceElements;
	}

	public String getCreationMethod() {
		return CreationMethod;
	}

	public String getCreationDescription() {
		return CreationDescription;
	}

	public String toString(){
		String output = "Source: [";
		output += "\n\tSourceElementType: " + SourceElementType;
		output += "\n\tSourceElements: ";
		for(SourceElement s : sourceElements){
			output += "[\n\t" + s + ",\n";
		}		
		output += "\t]\n\tCreationMethod: " + CreationMethod;
		output += "\n\tCreationDescription: " + CreationDescription;
		output += "\n]";
		return output;
	}
	
	
	
	public void setSourceElementType(String sourceElementType) {
		SourceElementType = sourceElementType;
	}

	public void setSourceElements(List<SourceElement> sourceElements) {
		sourceElements = sourceElements;
	}

	public void setCreationMethod(String creationMethod) {
		CreationMethod = creationMethod;
	}

	public void setCreationDescription(String creationDescription) {
		CreationDescription = creationDescription;
	}



	
	
}

